from base import By, webdriver, sleep
# 导入select类
from selenium.webdriver.support.ui import Select

driver = webdriver.Chrome()
driver.get('https://sahitest.com/demo/selectTest.htm')

# 创建select对象, 参数是要操作的select标签
s1 = driver.find_element(By.ID, 's1')
select = Select(s1)

# 选择option选项
# 通过索引
sleep(2)
select.select_by_index(2)

# 通过值
sleep(2)
select.select_by_value('50')

# 通过文本
sleep(2)
select.select_by_visible_text('Fax')

# 退出浏览器
sleep(3)
driver.quit()
